<template>
  <van-form @submit="submitForm" @failed="onFailed" ref="ruleFormRef" :model="form">
    <van-form-group>
      <van-field v-model="form.username" label="账号：" placeholder="请输入账号" clearable name="username" :rule="usernameRules">
      </van-field>
    </van-form-group>
    <van-form-group>
      <van-field v-model="form.password" label="密码：" placeholder="请输入密码" clearable name="password" type="password" :rule="passwordRules">
      </van-field>
    </van-form-group>
    <van-form-group>
      <van-field v-model="form.confirmPassword" label="确认密码：" placeholder="请再次输入密码" clearable name="confirmPassword" type="password" :rule="confirmPasswordRules">
      </van-field>
    </van-form-group>
    <van-form-group>
      <van-button block round type="primary" native-type="submit">注册</van-button>
    </van-form-group>
  </van-form>
  <div class="tip">注册成功后的用户可以用于登录</div>
</template>


<script setup>
import {ref,reactive} from 'vue'
import {getuser,register} from '../api'
import useToken from '../stores/token';
import useUser from '../stores/user';
import { useRouter } from 'vue-router';

const {updateToken}=useToken()
const {updateUser}=useUser()

const form =reactive({
  username:'',
  password:'',
  confimPassword:''
})
const ruleFormRef=ref()
const router=useRouter()


//定义验证规则
</script>